/* eslint-disable no-unused-vars */
import Vue from 'vue'
import VueI18n from 'vue-i18n'

Vue.config.devtools = true
import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // a modern alternative to CSS resets

import Element from 'element-ui'
import './assets/styles/element-variables.scss'

// import '@/assets/styles/index.scss' // global css
import '@/assets/simpleMindMap/icon-font/iconfont.css'
import '@/assets/family/font.css'
import '@/assets/styles/ruoyi.scss' // ruoyi css
import '@/assets/styles/theme-light.scss'
import App from './App'
import store from './store'
import router from './router'
import permission from './directive/permission'
// import '@/utils/rem.js'
import './assets/icons' // icon
import './permission' // permission control
import { getDicts } from '@/api/system/dict/data'
import { getComponentQueryId } from '@/api/system/desform/template/public'
import { getConfigKey, getConfigKeyToDownload } from '@/api/system/config'
import { getUser } from '@/api/system/user'
import { parseTime, resetForm, locationError, addDateRange, selectDictLabel, selectDictLabels, formattedNumber, download, moneyFormat, moneyFormatUnit, isEmpty, autoBusinessId, selectListLabel, decimalNum } from '@/utils/ruoyi'
import { downloadImage } from '@/utils/downloadImage'
// 下载excelGet请求
import { downLoadExcel } from '@/utils/excelDownload'
// 下载excelPost请求
import { downLoadExcelPost } from '@/utils/excelDownload'
// 前台配置
import { config, recorePath, fitChartFont } from '@/utils'
import Pagination from '@/components/Pagination'
// import globalUploader from '@/views/common/globalUploader.vue'
import elDragDialog from '@/directive/el-drag-dialog'
// 附件上传
import Upload from '@/components/File/Upload'
// 附件列表
import FileTable from '@/components/File/FileTable'
import FileView from '@/components/File/FileTable/view'
// 在线预览
import OnlinePreview from '@/components/File/OnlinePreview'
// 快速预览
import thumbnail from '@/components/File/OnlinePreview/thumbnail'

import FileListMin from '@/components/File/FileListMin'
// 空状态
import Empty from '@/components/Empty'
// 汇率转换
import ExchangeRate from '@/components/ExchangeRate'
import ExchangeRateMoney from '@/components/ExchangeRateMoney'
// 比例
import Ratio from '@/components/Ratio'
// import MoQuarterPicker from 'mo-quarter-picker'
// 选择用户
import UserSelect from '@/components/UserSelect/index'
// 部门选择
import DeptSelect from '@/components/UserSelect/deptIndex'
// 工作流相关的js
import { startProcessByMenu, stopProcess } from '@/api/act/process/actProcess'
// 工作流按钮组件
import FormBtn from '@/components/Act/FormBtn'
import ListBtn from '@/components/Act/ListBtn'
import ProcessPhase from '@/components/Act/ProcessPhase'
// 流程状态按钮
import ProcessStatus from '@/components/Act/ProcessStatus'
// 字典选择
import dictSelect from '@/components/DictSelect'
// 额外流程
import ExtraProcess from '@/components/ExtraProcess'
// 金额格式化
import Money from '@/components/Money'
// 聚焦行业
import FocusIndustry from '@/components/FocusIndustry'
// 字段提示组件
import ToolTipBreak from '@/components/ToolTipBreak'
import '@/assets/styles/ruoyi.scss' // ruoyi css
// 保存按钮
import SaveBtn from '@/components/SaveBtn'
import DatePicker from '@/components/DatePicker'
import backTop from '@/components/backTop'
// 币种
import Currency from '@/components/currency/index.vue'
// 投资主体组件
import InvestmentSelect from '@/components/InvestmentSelect/InvestmentSelect.vue'
// 项目组件
import DealSelect from '@/components/DealSelect/dealSelect.vue'
// 公司组件
import CompanySelect from '@/components/CompanySelect/companySelect.vue'

// 水印
import watermark from './utils/watermark.js'
Vue.prototype.$watermark = watermark

// tinymce组件子应用注册使用
import tinymceTextSub from '@/components/Tinymce'
Vue.component('tinymceTextSub', tinymceTextSub)
window.shareComponent = [
  tinymceTextSub
]

// iframe 高度自适应
import iframeResize from 'iframe-resizer/js/iframeResizer'
Vue.directive('resize', {
  bind: function(el, { value = {}}) {
    el.addEventListener('load', () => iframeResize(value, el))
  },
  unbind: function(el) {
    el.iFrameResizer.removeListeners()
  }
})
Vue.component('DatePicker', DatePicker)
Vue.component('backTop', backTop)
// el-transfer数据量大卡顿优化 && 添加虚拟滚动
import { RecycleScroller } from 'vue-virtual-scroller'
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
Vue.component('RecycleScroller', RecycleScroller)
import vueTransfer from '@/components/Element/transfer.vue'
Vue.component('vueTransfer', vueTransfer)

// 打印页面配置
import PageForm from '@/components/PageForm/index.vue'
Vue.component('PageForm', PageForm)
Vue.prototype.selectListLabel = selectListLabel

// 全局方法挂载
Vue.prototype.getDicts = getDicts
Vue.prototype.getConfigKey = getConfigKey
Vue.prototype.getConfigKeyToDownload = getConfigKeyToDownload
Vue.prototype.parseTime = parseTime
Vue.prototype.formattedNumber = formattedNumber
Vue.prototype.downloadImage = downloadImage
Vue.prototype.moneyFormat = moneyFormat
Vue.prototype.moneyFormatUnit = moneyFormatUnit
Vue.prototype.isEmpty = isEmpty
Vue.prototype.autoBusinessId = autoBusinessId
Vue.prototype.decimalNum = decimalNum
Vue.prototype.resetForm = resetForm
Vue.prototype.locationError = locationError
Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download
Vue.prototype.config = config
Vue.prototype.recorePath = recorePath
Vue.prototype.fitChartFont = fitChartFont // Echarts图表字体、间距自适应
Vue.prototype.getComponentQueryId = getComponentQueryId
Vue.prototype.WebNotify = WebNotify

// 挂载流程全局方法
// 启动流程
Vue.prototype.startProcessByMenu = startProcessByMenu
// 终止流程
Vue.prototype.stopProcess = stopProcess
// 下载Excel
Vue.prototype.downLoadExcel = downLoadExcel
// 下载ExcelPost请求
Vue.prototype.downLoadExcelPost = downLoadExcelPost

Vue.prototype.msgSuccess = function(msg) {
  this.$message({ showClose: true, message: msg, type: 'success' })
}

Vue.prototype.msgError = function(msg) {
  this.$message({ showClose: true, message: msg, type: 'error' })
}

Vue.prototype.msgInfo = function(msg) {
  this.$message({ showClose: true, message: msg, type: 'info' })
}

Vue.prototype.msgWarning = function(msg) {
  this.$message({ showClose: true, message: msg, type: 'warning' })
}

import Internationalization from '@/components/Internationalization'
// 复制文本
import VueClipboard from 'vue-clipboard2'
import VueFriendlyIframe from 'vue-friendly-iframe'

// import VConsole from 'vconsole'
// // 或者使用配置参数来初始化，详情见文档
// const vConsole = new VConsole({ theme: 'dark' })
// // // 接下来即可照常使用 `console` 等方法
// console.log('Hello world')
// // 结束调试后，可移除掉
// vConsole.destroy()

// markdown编辑器
import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
import elTableInfiniteScroll from 'el-table-infinite-scroll'
Vue.use(elTableInfiniteScroll)
Vue.use(VueClipboard)
Vue.use(VueFriendlyIframe)
// Vue.use(MoQuarterPicker)
Vue.use(mavonEditor)
// 全局组件挂载
Vue.component('Pagination', Pagination)
Vue.component('Internationalization', Internationalization)
// Vue.component('globalUploader', globalUploader)
Vue.component('UserSelect', UserSelect)
Vue.component('DeptSelect', DeptSelect)
Vue.component('Upload', Upload)
Vue.component('elDragDialog', elDragDialog)
Vue.component('OnlinePreview', OnlinePreview)
Vue.component('thumbnail', thumbnail)
Vue.component('ExtraProcess', ExtraProcess)
Vue.component('FileListMin', FileListMin)
Vue.component('ProcessPhase', ProcessPhase)
Vue.component('ProcessStatus', ProcessStatus)
Vue.component('Empty', Empty)
Vue.component('ExchangeRate', ExchangeRate)
Vue.component('ExchangeRateMoney', ExchangeRateMoney)
Vue.component('Ratio', Ratio)
// 选择字典
Vue.component('dictSelect', dictSelect)
Vue.component('Money', Money)
// 聚焦行业
Vue.component('FocusIndustry', FocusIndustry)
// 投资主体
Vue.component('InvestmentSelect', InvestmentSelect)
// 项目
Vue.component('DealSelect', DealSelect)
Vue.component('CompanySelect', CompanySelect)

// 币种
Vue.component('Currency', Currency)
// 字段提示
Vue.component('ToolTipBreak', ToolTipBreak)

Vue.component('FileTable', FileTable)
Vue.component('FileView', FileView)

Vue.directive('elDragDialog', elDragDialog)

// 工作流按钮组件
Vue.component('FormBtn', FormBtn)
Vue.component('ListBtn', ListBtn)
Vue.component('SaveBtn', SaveBtn)

Vue.use(permission)

import uploader from 'vue-simple-uploader'
Vue.use(uploader)

// 打印方法
import Print from '@/plugins/print/Print'
Vue.use(Print)

// 分割窗口
import splitPane from 'vue-splitpane'
Vue.component('splitPane', splitPane)

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 */

// Vue.use(Element, {
//   size: Cookies.get('size') || 'medium' // set element-ui default size
// })

Vue.prototype.$bus = new Vue()

Vue.config.productionTip = false

// 国际化配置
import { getLanguage } from '@/api/dev/language/sysLanguage'
import ElementLocale from 'element-ui/lib/locale'
import WebNotify from '@/api/sys/notification/webNotify'
// 引入VForm库
//  import vform from '../lib/VFormDesigner.umd.min.js'

// import { qiankunActions } from './qiankun/globalState'
// Vue.prototype.$actions = qiankunActions

// 引入VForm样式
//  import '../lib/VFormDesigner.css'
import obj1 from '@/components/SimpleMindMap/lang/zh_cn'
import obj2 from '@/components/SimpleMindMap/lang/en_us'
getLanguage().then(response => {
  Vue.use(VueI18n)
  const i18n = window.i18n = new VueI18n({
    locale: response.language, // 语言标识, 通过切换locale的值来实现语言切换,this.$i18n.locale
    messages: {
      'zh_cn': Object.assign({}, response.languageData, obj1),
      'en_us': Object.assign({}, response.languageData, obj2),
      'zh_tw': response.languageData,
      'ja_jp': response.languageData
    },
    silentTranslationWarn: true // 关闭警告
  })
  ElementLocale.i18n((key, value) => i18n.t(key, value))
  Vue.use(Element, {
    size: Cookies.get('size') || 'medium' // set element-ui default size
  })
  // 全局注册VForm(同时注册了v-form-designe、v-form-render等组件)
  //  Vue.use(vform)
  new Vue({
    el: '#app',
    i18n,
    router,
    store,
    render: h => h(App)
  })
})

